/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.uniroma3.dia.tta.frame;

import it.uniroma3.dia.tta.Application;
import it.uniroma3.dia.tta.Controller;
import it.uniroma3.dia.tta.utility.ImagePanel;
import it.uniroma3.dia.tta.utility.InformationMap;
import java.awt.Frame;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JInternalFrame;
import javax.swing.JTextField;

/**
 *
 * @author Fabio Cumbo, Alessandro Giacomini
 * @application TwitterTextAnalyzer
 * @version 1.0
 * @organization Università degli studi Roma Tre - Dipartimento di Informatica e Automazione
 * 
 */
public class MainWindow extends javax.swing.JFrame implements Application {

    /**
     * Creates new form MainWindow
     */
    public MainWindow() {
        initComponents();
        informationMap = new InformationMap();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        trainPath_text = new javax.swing.JTextField();
        loadTrainDataset_button = new javax.swing.JButton();
        loadTrainDataset_button.addActionListener(new Controller());
        stopWordsPath_text = new javax.swing.JTextField();
        loadStopWordsDataset_button = new javax.swing.JButton();
        loadStopWordsDataset_button.addActionListener(new Controller());
        jSeparator1 = new javax.swing.JSeparator();
        plotWordFrequenciesDistribution_button = new javax.swing.JButton();
        plotWordFrequenciesDistribution_button.addActionListener(new Controller());
        plotTagsComparisonDistribution_button = new javax.swing.JButton();
        plotTagsComparisonDistribution_button.addActionListener(new Controller());
        testPath_text = new javax.swing.JTextField();
        loadTestDataset_button = new javax.swing.JButton();
        loadTestDataset_button.addActionListener(new Controller());
        runNaiveBayesClassifier_button = new javax.swing.JButton();
        runNaiveBayesClassifier_button.addActionListener(new Controller());
        jButton9 = new javax.swing.JButton();
        jButton10 = new javax.swing.JButton();
        jButton13 = new javax.swing.JButton();
        wordFrequenciesDistribution_frame = new javax.swing.JInternalFrame();
        tagsComparisonDistribution_frame = new javax.swing.JInternalFrame();
        jSeparator3 = new javax.swing.JSeparator();
        jPanel2 = new javax.swing.JPanel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("TwitterTextAnalyzer - 2013");
        setResizable(false);

        trainPath_text.setEnabled(false);

        loadTrainDataset_button.setText("Load Train Dataset");

        stopWordsPath_text.setEnabled(false);

        loadStopWordsDataset_button.setText("Load StopWords Dataset");

        plotWordFrequenciesDistribution_button.setText("Plot word frequencies distribution");
        plotWordFrequenciesDistribution_button.setEnabled(false);

        plotTagsComparisonDistribution_button.setText("Plot pairwise comparison of tags distribution");
        plotTagsComparisonDistribution_button.setEnabled(false);

        testPath_text.setEnabled(false);

        loadTestDataset_button.setText("Load Test Dataset");
        loadTestDataset_button.setEnabled(false);

        runNaiveBayesClassifier_button.setText("Run Naïve Bayes Classifier");
        runNaiveBayesClassifier_button.setEnabled(false);

        jButton9.setText("?");
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                loadStopWordsDataset_help(evt);
            }
        });

        jButton10.setText("?");
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                loadTrainDataset_help(evt);
            }
        });

        jButton13.setText("?");
        jButton13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                loadTestDataset_help(evt);
            }
        });

        wordFrequenciesDistribution_frame.setTitle("Word frequencies distribution");
        wordFrequenciesDistribution_frame.setVisible(true);

        javax.swing.GroupLayout wordFrequenciesDistribution_frameLayout = new javax.swing.GroupLayout(wordFrequenciesDistribution_frame.getContentPane());
        wordFrequenciesDistribution_frame.getContentPane().setLayout(wordFrequenciesDistribution_frameLayout);
        wordFrequenciesDistribution_frameLayout.setHorizontalGroup(
            wordFrequenciesDistribution_frameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        wordFrequenciesDistribution_frameLayout.setVerticalGroup(
            wordFrequenciesDistribution_frameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        tagsComparisonDistribution_frame.setTitle("Pairwise comparison of tags distributions");
        tagsComparisonDistribution_frame.setVisible(true);

        javax.swing.GroupLayout tagsComparisonDistribution_frameLayout = new javax.swing.GroupLayout(tagsComparisonDistribution_frame.getContentPane());
        tagsComparisonDistribution_frame.getContentPane().setLayout(tagsComparisonDistribution_frameLayout);
        tagsComparisonDistribution_frameLayout.setHorizontalGroup(
            tagsComparisonDistribution_frameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        tagsComparisonDistribution_frameLayout.setVerticalGroup(
            tagsComparisonDistribution_frameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 235, Short.MAX_VALUE)
        );

        jSeparator3.setOrientation(javax.swing.SwingConstants.VERTICAL);

        jPanel2 = new ImagePanel(new ImageIcon("img/tta_mini_logo.jpg").getImage());

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(testPath_text, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(loadTestDataset_button, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton13))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(stopWordsPath_text)
                                    .addComponent(trainPath_text))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(loadStopWordsDataset_button, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(loadTrainDataset_button, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jButton9, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jButton10, javax.swing.GroupLayout.Alignment.TRAILING)))
                            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(plotTagsComparisonDistribution_button, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(plotWordFrequenciesDistribution_button, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(runNaiveBayesClassifier_button, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(463, 463, 463))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addComponent(wordFrequenciesDistribution_frame))))
                    .addComponent(tagsComparisonDistribution_frame))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(trainPath_text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(loadTrainDataset_button)
                            .addComponent(jButton10))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(stopWordsPath_text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(loadStopWordsDataset_button)
                            .addComponent(jButton9))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(plotWordFrequenciesDistribution_button)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(plotTagsComparisonDistribution_button)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButton13)
                            .addComponent(loadTestDataset_button)
                            .addComponent(testPath_text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(runNaiveBayesClassifier_button))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(wordFrequenciesDistribution_frame))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tagsComparisonDistribution_frame, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jMenu2.setText("Help");

        jMenuItem1.setText("About TwitterTextAnalyzer");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                information_button(evt);
            }
        });
        jMenu2.add(jMenuItem1);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void loadTrainDataset_help(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadTrainDataset_help
        HelpWindow help = new HelpWindow();
        help.setText(informationMap.getInformationAbout("_TRAIN_"));
        help.setVisible(true);
    }//GEN-LAST:event_loadTrainDataset_help

    private void loadStopWordsDataset_help(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadStopWordsDataset_help
        HelpWindow help = new HelpWindow();
        help.setText(informationMap.getInformationAbout("_STOPWORDS_"));
        help.setVisible(true);
    }//GEN-LAST:event_loadStopWordsDataset_help

    private void loadTestDataset_help(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadTestDataset_help
        HelpWindow help = new HelpWindow();
        help.setText(informationMap.getInformationAbout("_TEST_"));
        help.setVisible(true);
    }//GEN-LAST:event_loadTestDataset_help

    private void information_button(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_information_button
        InformationWindow info = new InformationWindow();
        info.setVisible(true);
    }//GEN-LAST:event_information_button

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton13;
    private javax.swing.JButton jButton9;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JButton loadStopWordsDataset_button;
    private javax.swing.JButton loadTestDataset_button;
    private javax.swing.JButton loadTrainDataset_button;
    private javax.swing.JButton plotTagsComparisonDistribution_button;
    private javax.swing.JButton plotWordFrequenciesDistribution_button;
    private javax.swing.JButton runNaiveBayesClassifier_button;
    private javax.swing.JTextField stopWordsPath_text;
    private javax.swing.JInternalFrame tagsComparisonDistribution_frame;
    private javax.swing.JTextField testPath_text;
    private javax.swing.JTextField trainPath_text;
    private javax.swing.JInternalFrame wordFrequenciesDistribution_frame;
    // End of variables declaration//GEN-END:variables

    private InformationMap informationMap;
    
    @Override
    public void setVisibleOverride(boolean visible) {
        this.setVisible(visible);
    }

    @Override
    public void setDefaultCloseOperationOverride(int _DO_) {
        this.setDefaultCloseOperation(_DO_);
    }

    @Override
    public JButton getLoadStopWordsDataset_button() {
        return loadStopWordsDataset_button;
    }

    @Override
    public JButton getLoadTestDataset_button() {
        return loadTestDataset_button;
    }

    @Override
    public JButton getLoadTrainDataset_button() {
        return loadTrainDataset_button;
    }

    @Override
    public JButton getPlotTagsComparisonDistribution_button() {
        return plotTagsComparisonDistribution_button;
    }

    @Override
    public JButton getPlotWordFrequenciesDistribution_button() {
        return plotWordFrequenciesDistribution_button;
    }

    @Override
    public JButton getRunNaiveBayesClassifier_button() {
        return runNaiveBayesClassifier_button;
    }

    @Override
    public JTextField getStopWordsPath_text() {
        return stopWordsPath_text;
    }

    @Override
    public JTextField getTestPath_text() {
        return testPath_text;
    }

    @Override
    public JTextField getTrainPath_text() {
        return trainPath_text;
    }

    @Override
    public JInternalFrame getTagsComparisonDistribution_frame() {
        return tagsComparisonDistribution_frame;
    }

    @Override
    public JInternalFrame getWordFrequenciesDistribution_frame() {
        return wordFrequenciesDistribution_frame;
    }
    
    @Override
    public Frame getFrame() {
        return getFrames()[0];
    }
    
}
